<template>
  <el-pagination
    :current-page="props.page"
    :page-size="props.limit"
    :page-sizes="[10, 20, 30, 40, 50, 100]"
    :total="total"
    :layout="layout"
    @current-change="handleCurrentChange"
  />
</template>

<script lang='ts' setup>
const props = defineProps({
  page: {
    type: Number,
    required: true
  },
  limit: {
    type: Number,
    required: true
  },
  total: {
    type: Number,
    required: true
  },
  layout: {
    type: String,
    default: 'total, prev, pager, next'
  }
})

interface EmitType {
  (e: 'update:page', page: number): void,
  (e: 'update:limit', limit: number): void
}

const emit = defineEmits<EmitType>()

const handleCurrentChange = (page: number) => {
  emit('update:page', page)
}
</script>

<style lang='scss' scoped></style>
